package com.scalar.chiptrack.sales.actions.quote;

import com.scalar.chiptrack.ChipTrackAction;
import com.scalar.chiptrack.ChipTracActionCommand;
import com.scalar.chiptrack.sales.forms.quote.PreviousQuotationLatestPriceSearchActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
  
/**
 * User: Ganesh
 * Date: May 13, 2008
 * Time: 5:42:17 PM
 */
public class PreviousQuotationLatestPriceSearchAction extends ChipTrackAction {
    public ActionForward execute(ActionMapping mapping,
                                       ActionForm form,
                                       HttpServletRequest request,
                                       HttpServletResponse response) throws IOException, ServletException {
        ChipTracActionCommand chipTracActionCommand;
        ActionForward forward=null;
        try {
            //System.out.println("PreviousQuotationLatestPriceSearchAction.executeAction");
            PreviousQuotationLatestPriceSearchActionForm searchActionForm=(PreviousQuotationLatestPriceSearchActionForm) form;
            PreviousQuotationLatestPriceSearchCommandFactory commandFactory=PreviousQuotationLatestPriceSearchCommandFactory.getInstance();
            String subAction = searchActionForm.getSubAction();
            //System.out.println("subAction = " + subAction);
            chipTracActionCommand = commandFactory.getActionCommand(subAction);
            if(chipTracActionCommand!=null)
                forward = chipTracActionCommand.executeCommand(mapping,form,request,response);
            else
                forward = null;
            
        } catch (Exception e) {
            System.out.println("PreviousQuotationLatestPriceSearchAction.executeAction"+e);
        }

        return forward;
    }
}
